

::delete temp file
IF EXIST "tmp\pack-all.css" del "tmp\pack-all.css"
IF EXIST "tmp\allFileList.css" del "tmp\allFileList.css"
IF EXIST "result\pack-all-min.css" del "result\pack-all-min.css"



::pack all file into one file: tmp\pack-all.css
cd src
for /f %%i in (CssLoader.js) do call :Merge %%i
echo "success merge file to tmp\pack-all.css from CssLoader.css @@@@@@@@@@@@@"

::compress tmp\pack-all.css
call :Compress
IF NOT EXIST "..\result\pack-all-min.css" (
echo "fail compress file from tmp\pack-all.css @@@@@@@@@@@@@"
GOTO:EOF
)
cd ../

::Copy file to outer folder
copy  .\result\pack-all-min.css .\..\contract-min.css



::delefe file in fileList.txt
for /f %%i in (.\tmp\allFileList.css) do call:DelFile: %%i
echo "success delete file in fileList.txt @@@@@@@@@@@@@"

echo "@@@@@@@@@@@@@ All operation success ! @@@@@@@@@@@@@"
GOTO:EOF


:DelFile
::IF EXIST "%CD%\%1" del "%CD%\%1"
echo simulate delete file :%1
GOTO:EOF


:Compress
java -jar ..\lib\yuicompressor-2.4.6.jar --type css --charset utf-8 ..\tmp\pack-all.css -o ..\result\pack-all-min.css
GOTO:EOF

:Merge
set str=%1
set retStr=""
echo -----------------%str% - %retStr%
call ..\strsticpy.bat %str% ' retStr
echo ++++++++++++====%retStr%
if "%retStr%" equ ""  goto :leaveOut

cd ..\

if not exist %retStr%  goto :leaveOut

echo %retStr% >> .\tmp\allFileList.css

type %retStr% >> .\tmp\pack-all.css

:leaveOut
cd .\src\
GOTO:EOF